
import Vue from "vue";
import Vuex from "vuex";
import { setAvatar, getAvatar } from '@/utils/storage'

Vue.use(Vuex);

export default new Vuex.Store({
    state: {
        userInfo: JSON.parse(getAvatar('userInfo')) || {},
        addressInfo: {},
        // 当前收获地址
        currentAddress: {},
    },
    mutations: {
        setUserInfo(state, obj) {
            state.userInfo = obj;
            setAvatar('userInfo', JSON.stringify(obj))
        },
        setAddress(state, obj) {
            state.addressInfo = obj
        },
        setcurrentAddress(state, obj) {
            state.currentAddress = obj
            localStorage.setItem('currentCity', JSON.stringify(obj))
        }
    },
    actions: {},
    modules: {},
});
